package com.bjmashibing.system.OSFileIO.davidDemo;

import java.io.*;

public class BoscDemo {

    static String path="path";
    static String skip="@!@";

    private boolean demo1() throws Exception {

        File file=new File(path);

        FileInputStream fileInputStream=new FileInputStream(file);

        InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "utf-8");


        FileOutputStream fileOutputStream=new FileOutputStream(path);
        OutputStreamWriter outputStreamWriter=new OutputStreamWriter(fileOutputStream);


        char[] chars=new char[4096];

        int length=0;

        int skipCount=0;

        int fileCount=Integer.MIN_VALUE;

        while ((length=inputStreamReader.read(chars))!=-1){

            String tempStr=new String(chars);

            String[] res = tempStr.split(skip);

            fileCount=Integer.parseInt(res[0]);

            for (int i=0;i<chars.length;i++){
                if (chars[i]=='@'&&chars[i+1]=='!'&&chars[i+2]=='@'){
                    skipCount++;
                }
            }
        }

        return fileCount==skipCount?true:false;

    }


}
